using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Puppy.DependencyInjection;

namespace Puppy.Domain.Services
{
    public abstract class DomainService : IDomainService
    {
        public ILazyServiceProvider LazyServiceProvider { get; set; }

        protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService<ILoggerFactory>();

        protected IAsyncQueryableExecuter AsyncExecuter => LazyServiceProvider.LazyGetRequiredService<IAsyncQueryableExecuter>();

        protected ILogger Logger => LazyServiceProvider.LazyGetService<ILogger>(provider => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance);
    }
}
